package game.entity;

import game.logic.GameControl;
import game.screen.ScreenGameLost;
import game.screen.ScreenPlaying;
import game.shared.Constants;


public class Army extends AbsSprite  {
	
	GameControl gameControl;
	boolean check = false;
	
	public Army(GameControl gameControl, Army army){
		super(army);
		this.gameControl = gameControl;
	}
	public Army(GameControl gameControl, SpriteManager _SpriteManager, String imgPath, int idAnimation, float frameDuration, int num_rows, int num_clus) {
		super(_SpriteManager, imgPath,idAnimation,  frameDuration,  num_rows, num_clus);
		this.gameControl = gameControl;
	}
	
	public Army(GameControl gameControl, SpriteManager _SpriteManager, String imgPath,int idAnimation, float frameDuration, int scrX, int scrY, int frameWidth, int frameHeight, int num_rows, int num_clus) {
		super(_SpriteManager, imgPath,idAnimation,  frameDuration,  scrX, scrY, frameWidth, frameHeight, num_rows, num_clus);
		this.gameControl = gameControl;
	}
	
	public Army(GameControl gameControl, SpriteManager _SpriteManager, String configueFilePath)
	{
		super(_SpriteManager, configueFilePath);
		this.gameControl = gameControl;
	}

	public Army(GameControl gameControl, AbsSprite army)
	{
		super(army);
		this.gameControl = gameControl;
	}
	
	@Override
	public void update() {
		check = false;
		for(int i=0; i<spriteMamanger.count(); i++)
			if(this.getBoundingRectangle().overlaps(spriteMamanger.getByIndex(i).getBoundingRectangle()))
				check = true;
		if(check == true)
			this.setState(Constants.HOME_ATTACKED);
		else
			if(Constants.HP>50)
				this.setState(Constants.HOME_CLOSEDORE);
			else
				this.setState(Constants.HOME_OPENDORE);
		if (Constants.HP <= 0){
			gameControl.setScreen(Constants.SCREEN_SELECT_LEVEL);
		}
	}
}
